package com.lsh.payment.core.service.async.impl;

import com.alibaba.fastjson.JSON;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import com.lsh.payment.core.model.payasync.ResultNotifyModel;
import com.lsh.payment.core.service.async.IEventListener;
import com.lsh.payment.core.service.notify.BusinessNotifyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Project Name: lsh-payment
 * @author jingyuan
 * Date: 16/12/22
 * 北京链商电子商务有限公司
 * Package com.lsh.payment.core.service.AsyncService
 * desc:异步处理监听类
 * @author peter
 */
@Component
public class NotifyEventListener implements IEventListener {
    private Logger logger = LoggerFactory.getLogger(NotifyEventListener.class);

    @Autowired
    private BusinessNotifyService businessNotifyService;
    
    /**
     * 结果回调 ResultNotifyModel
     *
     * @param resultNotifyModel 监听类
     */
    @Subscribe
    @AllowConcurrentEvents
    public void sendNotify(ResultNotifyModel resultNotifyModel) {
        logger.info(" 通知业务支付成功 resultNotifyModel is " + JSON.toJSONString(resultNotifyModel));
        businessNotifyService.dealNotify(resultNotifyModel.getPayDeal());
    }

}
